package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Category;

public class CategorySqlProvider {

    public String insertSelective(Category record) {
        BEGIN();
        INSERT_INTO("st_category");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getMoney() != null) {
            VALUES("money", "#{money,jdbcType=VARCHAR}");
        }
        
        if (record.getPersonnel() != null) {
            VALUES("personnel", "#{personnel,jdbcType=VARCHAR}");
        }
        
        if (record.getDatetime() != null) {
            VALUES("datetime", "#{datetime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getRemarks() != null) {
            VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getClid() != null) {
            VALUES("clid", "#{clid,jdbcType=INTEGER}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Category record) {
        BEGIN();
        UPDATE("st_category");
        
        if (record.getMoney() != null) {
            SET("money = #{money,jdbcType=VARCHAR}");
        }
        
        if (record.getPersonnel() != null) {
            SET("personnel = #{personnel,jdbcType=VARCHAR}");
        }
        
        if (record.getDatetime() != null) {
            SET("datetime = #{datetime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getRemarks() != null) {
            SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getClid() != null) {
            SET("clid = #{clid,jdbcType=INTEGER}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}